#pragma once
#ifndef WORLDMODEL_H
#define WORLDMODEL_H

#include <vector>
#include "EntityPlayer.h"			
#include "EntityProjectile.h"
#include <tinyxml.h>

class CEntityExplosion;
class CEntityEnemy;
class CEntityCloud;
class CEntityBackground;
using namespace std;

class CWorldModel
{
private:
	
	static CWorldModel* instance;				//variable for the singleton
	vector<CWorldEntity*> vectorEntity;			//vector which store every entities

	int indexPlayer;
	int indexBoss;

	bool exit;
	bool gameOver;
	int timeStartLevel;
	int numberOfPoint;

	int timeBeginDisplayYOUWIN;
	int timeDisplayYOUWIN;
	int timeBeginDisplayGAMEOVER;
	int timeDisplayGAMEOVER;
protected:
	CWorldModel(void);
	~CWorldModel(void);
public:
	
	//Function to return the unique object of the CWorldModel class
	static CWorldModel& getInstance(void);
	

	//Function to create entities
	void CWorldModel::createPlayer(int startPositionX, int startPositionY, int health, 
		int speed, int state, int collisionCost, bool active, int indexAnimationUp, 
		int indexAnimationLeft, int indexAnimationRight, int speedAnimation);
	void CWorldModel::createBackground(int startPositionBackgroundX, int startPositionBackgroundY, 
		int indexSprite1, int indexSprite2, int speed, bool active);
	void CWorldModel::createCloud(int startPositionX, int startPositionY, int indexSprite, int speed,
		int timeBetweenCloud, bool active);
	void CWorldModel::createBoss( int indexProjectileLeft, int indexProjectileRight, int timeToSpawn);


	void CWorldModel::addEntity(CWorldEntity* const entity);
	void CWorldModel::loadLevel(TiXmlHandle handle);
	void CWorldModel::resetLevel();

	

	//function to update and render entities
	void CWorldModel::update(void);
	void CWorldModel::render(void);


	//gettors
	int CWorldModel::getCurrentPosX(int index)const;
	int CWorldModel::getCurrentPosY(int index)const;
	int CWorldModel::getState(int index)const;
	int CWorldModel::getSprite(int index)const;
	int CWorldModel::getFrame(int index)const;	
	int CWorldModel::getNumberOfPoint(void)const;
	
	int CWorldModel::getExit(void)const;
	int CWorldModel::getNumberOfLife(int index)const;
	int CWorldModel::getTotalHealth(int index)const;
	int CWorldModel::getCurrentHealth(int index)const;
	bool CWorldModel::getActive(int index)const;
	int CWorldModel::getEntityVectorSize(void)const;
	CWorldEntity* CWorldModel::getEntityPnter(int indexEntity)const;
	int getTimeStartLevel(void)const;
	bool getGameOver(void)const;
	int CWorldModel::getIndexPlayer()const;


	//settors	
	void CWorldModel::setExit(bool exit);
	void CWorldModel::setTimeStartLevel(int timeStartLevel);
	void CWorldModel::setNumberOfPoint(int numberOfPoint);
	void CWorldModel::setGameOver(bool gameOver);

	//function to check collision between otherEntity and all the other entities
	CWorldEntity* CWorldModel::checkCollision(CWorldEntity* otherEntity);

	//function to destroy the singleton
	void CWorldModel::Close(void);
};
#define WMODEL CWorldModel::getInstance()


#endif